<?php

namespace app\mall\event\subscribes;

use app\admin\logic\system\Log;
use think\Event;

class Product
{
    public function subscribe(Event $event)
    {
        $admin = '管理员【' . request()->user->user_name . '/' . request()->user->id . '】';

        /** 新建 */
        $event->listen('AfterCreate', function ($data) use ($admin) {
            Log::write($admin . '新建了商品《' . $data->title . '》', 'product', 'create');
        });
        /** 新建 */
        $event->listen('AfterUpdate', function ($data) use ($admin) {
            Log::write($admin . '编辑了商品《' . $data->title . '》', 'product', 'update');
        });
        /** 新建 */
        $event->listen('AfterDelete', function ($data) use ($admin) {
            Log::write($admin . '删除了商品《' . $data->title . '》', 'product', 'delete');
        });

    }
}
